package org.grayrabbit.cms.plugin;

import java.util.HashMap;
import java.util.Map;

/**
 * @author sys53
 * @version 1.0
 * @created 06-一月-2012 16:06:03
 */
public class PluginManagerState {
	private Map<String,Boolean> map = new HashMap<String,Boolean>();
	
	public PluginManagerState(Map<String,Boolean> map){
		this.map = map;
	}
	/**
	 * 
	 * @param key
	 */
	public Boolean getState(String key){
		return this.map.get(key);
	}

	public Map<String, Boolean> getMap() {
		return map;
	}
	/**
	 * 
	 * @param plugin
	 */
	public boolean isEnabled(Plugin plugin){
		Boolean bool = getState(plugin.getKey());
		return bool==null?plugin.isDefaultEnabled():bool.booleanValue();
	}

	/**
	 * 
	 * @param key
	 */
	public void removeState(String key){
		this.map.remove(key);
	}

	/**
	 * 
	 * @param enabled
	 * @param key
	 */
	public void setState( String key,Boolean enabled){
		this.map.put(key, enabled);
	}
	public boolean isEnabled(ModuleDescriptor pluginModule) {
		return false;
	}

}